package com.walkline.travelassistant.dao;

import org.json.me.JSONArray;
import org.json.me.JSONException;
import org.json.me.JSONObject;

import com.walkline.travelassistant.TravelAssistantException;
import com.walkline.travelassistant.TravelAssistantSDK;
import com.walkline.travelassistant.inf.Taxi;
import com.walkline.util.Function;

public class TravelAssistantTaxi extends TravelAssistantObject implements Taxi
{
	private int _distance = 0;
	private String _distance_str = "";
	private String _total_price = "";
	private String _remark = "";

	public TravelAssistantTaxi(TravelAssistantSDK travelAssistant, JSONObject jsonObject) throws TravelAssistantException
	{
		super(travelAssistant, jsonObject);

		JSONObject taxiObject = jsonObject;
		if (taxiObject != null)
		{
			_distance = taxiObject.optInt("distance");
			_distance_str = Function.convertDistance2String(_distance);
			_remark = taxiObject.optString("remark");

			try {
				JSONArray details = taxiObject.optJSONArray("detail");
				_total_price = ((JSONObject) details.get(0)).optString("total_price") + " 元";
			} catch (JSONException e) {Function.errorDialog(e.toString());}
		}
	}

	public int getDistance() {return _distance;}

	public String getDistanceStr() {return _distance_str;}

	public String getTotalPrice() {return _total_price;}

	public String getRemark() {return _remark;}
}